package day22;
import java.util.HashMap;
import java.util.Map;
public class Student {
    private String name;
    private int age;
    public Student(){
    }
    public Student(String name, int age ) {
        this.name = name;
        this.age = age;

    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public static void main(String[] args) {
        //创建数据和对象
        Student th=new Student("朱玉",12);
        Student th1=new Student("玉竹",1);
        Student th2=new Student("主语",20);
        Student th3=new Student("皇帝",100);
        //创建集合
        Map Student=new HashMap();
        //添加数据
         Student.put(th,"北京");
        Student.put(th1,"南京");
        Student.put(th2,"中国");
        Student.put(th3,"美国");
        //遍历
        for(Object O:Student.keySet())//KeySet是取值
            //强制转换
        {Student b=(Student) O;
            System.out.println("姓名是:"+b.getName()+"年龄:"+b.getAge()+"地址:"+Student.get(b));
        }
    }
}

